home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol194 / kermasm.arc / MSRECV.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-11-14  |  19.8 KB  |  600 lines

  1.     public    read12, read2, rin21, rfile3, read, updrtr, nak, rrinit
  2.     include msdefs.h    
  3.  
  4. datas     segment    public 'datas'
  5.     extrn    fcb:byte, data:byte, bufpnt:word, chrcnt:word, curchk:byte
  6.     extrn    comand:byte, flags:byte, pack:byte, trans:byte
  7.  
  8. ermes7  db      '?Unable to receive initiate$'
  9. ermes8  db      '?Unable to receive file name$'
  10. ermes9  db      '?Unable to receive end of file$'
  11. erms10  db      '?Unable to receive data$'
  12. infms1  db    cr,'           Receiving: In progress$'
  13. infms3  db      'Completed$'
  14. infms4  db      'Failed$'
  15. infms6  db      'Interrupted$'
  16. remmsg1    db    'Kermit-MS: Invalid filename'
  17. filhlp2 db      ' Confirm with carriage return or specify name '
  18.     db    ' to use for incoming file $'
  19. ender    db    bell,bell,'$'
  20. crlf    db    cr,lf,'$'
  21. temp    dw    0
  22. filopn    db    0        ; Says if disk file is open.
  23. datas    ends
  24.  
  25. code    segment    public
  26.     extrn    gofil:near, outbuf:near, fixfcb:near, comnd:near
  27.     extrn    spack:near, rpack:near, serini:near, serrst:near
  28.     extrn    spar:near, rpar:near, init:near, init1:near, cxmsg:near
  29.     extrn    error:near, ptchr:near, erpos:near, rtpos:near
  30.     extrn    stpos:near, rprpos:near, nppos:near, nout:near
  31.     extrn    dodec:near, doenc:near, errpack:near
  32.     extrn    send11:near, clrmod:near
  33.     assume  cs:code, ds:datas
  34.  
  35.  
  36. ; Update retry count and fall through to send a NAK.
  37. nak0:    call updrtr        ; Update retry count.
  38.  
  39. nak:    mov ax,pack.pktnum     ; Get the packet number we're waiting for.
  40.         mov pack.argblk,ax
  41.         mov pack.argbk1,0
  42.     mov cx,0        ; No data, but this may change.
  43.     call doenc        ; So call encode.
  44.         mov ah,'N'              ; NAK that packet.
  45.         call spack
  46.      jmp abort
  47.      nop            ; So 'jmp rskp' in SPACK comes here. [19a]
  48.         ret                     ; Go around again.
  49.  
  50. updrtr:    cmp pack.state,'A'    ; Supposed to abort?
  51.     je upd0            ; Yes, don't bother with retry count.
  52.     inc pack.numrtr        ; Increment the number of retries.
  53.     cmp flags.xflg,1    ; Writing to screen?
  54.     je upd0
  55.     call rtpos        ; Position cursor.
  56.     mov ax,pack.numrtr
  57.     call nout        ; Write the number of retries.
  58. upd0:    ret
  59.  
  60. ;       Abort
  61. ABORT   PROC    NEAR
  62.     cmp filopn,0        ; Disk file open?
  63.     je abort0        ; No so don't close.
  64.     cmp flags.xflg,1    ; Writing to the screen?
  65.     je abort0        ; Yes, don't close "file".
  66.     mov ah,closf        ; Close the file and ignore errors.
  67.     mov dx,offset fcb
  68.     int dos
  69. abort0:    mov pack.state,'A'      ; Otherwise abort.
  70.         ret
  71. ABORT   ENDP
  72.  
  73. ; init variables for read...
  74. rrinit    proc    near
  75.     mov pack.numpkt,0    ; Set the number of packets to zero.
  76.     mov pack.numrtr,0    ; Set the number of retries to zero.
  77.     mov pack.pktnum,0    ; Set the packet number to zero.
  78.     mov pack.numtry,0    ; Set the number of tries to zero.
  79.     ret
  80. rrinit    endp
  81.  
  82. ;    RECEIVE command  --  Some code moved to the GET routine. [21a] 
  83.  
  84. READ    PROC    NEAR        
  85.     mov comand.cmrflg,1    ; Say we're receiving a file. [21a start]
  86.     mov comand.cmcr,1    ; Allow bare CR after RECEIVE.
  87.     mov flags.droflg,0    ; Override default drive flag.
  88.     mov flags.nmoflg,0    ; Override file name from other host?
  89.     mov dx,offset fcb    ; Put filename here. 
  90.     mov bx,offset filhlp2    ; Text of help message.
  91.     mov ah,cmifi        ; Read in the filename.
  92.     call comnd        
  93.      jmp r                
  94.     mov comand.cmrflg,0    ; Reset flag.
  95.     mov comand.cmcr,0
  96.     mov flags.wldflg,0    ; Just in case
  97.     mov ah,cmcfm        ; Get a confirm.
  98.     call comnd
  99.      jmp r
  100. read1:    cmp flags.remflg,0    ; remote mode?
  101.     jne read12        ; yes, no printing
  102.     cmp flags.destflg,2    ; Receiving to the screen? [27c]
  103.     je read12        ; Yes no printing [27c]
  104.     call init
  105. read12:    mov flags.cxzflg,0    ; Reset ¬X/¬Z flag. [20c] 
  106.     call rrinit        ; init variables for read
  107.     call serini        ; Initialize serial port. [14]
  108.     cmp flags.remflg,0    ; in remote mode?
  109.     jne read12a        ; yes, no printing
  110.     call init1        ; Clear the line and initialize the buffers.
  111.     cmp flags.destflg,2    ; Receiving to the screen? [27c]
  112.     je read12a        ; Yes no printing [27c]
  113.     call stpos
  114.     mov ah,prstr        ; Be informative.
  115.     mov dx,offset infms1
  116.     int dos
  117.     call rtpos        ; Position cursor.
  118.     mov ax,pack.numrtr
  119.     call nout        ; Write the number of retries.
  120. read12a:mov pack.state,'R'    ; Set the state to receive initiate.
  121. read2:     cmp flags.xflg,1    ; Are we receiving to the screen. [21c]
  122.     je read21        ; Skip the screen stuff. [21c]
  123.     cmp flags.remflg,0    ; maybe remote mode?
  124.     jne read21        ; yup, skip the screen stuff
  125.     call nppos        ; Position cursor for number of packets msg.
  126.     mov ax,pack.numpkt
  127.     call nout        ; Write the number of packets.
  128. read21: mov ah,pack.state    ; Get the state. [21c]
  129.     cmp ah,'D'        ; Are we in the data send state?
  130.     jne read3
  131.     call rdata
  132.     jmp read2
  133. read3:  cmp ah,'F'        ; Are we in the file receive state?
  134.     jne read4
  135.     call rfile        ; Call receive file.
  136.     jmp read2
  137. read4:  cmp ah,'R'        ; Are we in the receive initiate state?
  138.     jne read5
  139.     call rinit
  140.     jmp read2
  141. read5:  cmp ah,'C'        ; Are we in the receive complete state?
  142.     jne read6
  143.     call serrst        ; Reset serial port. [14]
  144.     cmp flags.xflg,0    ; Did we write to the screen? [21c]
  145.     je read51        ; No so print status. [21c]
  146.     cmp flags.destflg,2    ; Receiving to screen? [27c]
  147.     je read51a        ; Yes don't reset. [27c]
  148.     mov flags.xflg,0    ; Reset it. [21c]
  149.     jmp rskp        ; Yes, so just return. [21c]    
  150. read51:    cmp flags.remflg,0    ; remote mode?
  151.     jne read51a        ; yes, keep going
  152.     call stpos        ; Position cursor. [21c]
  153.     mov ah,prstr
  154.     mov dx,offset infms3    ; Plus a little cuteness.
  155.     cmp flags.cxzflg,0    ; Completed or interrupted? [20c]
  156.     je read13        ; Ended normally. [20c]
  157.     mov dx,offset infms6    ; Say was interrupted. [20c]
  158. read13: int dos
  159.     cmp flags.belflg,0    ; Bell desired?  [17a]
  160.     je readnb        ; No.  [17a]
  161.     mov dx,offset ender    ; Ring them bells.    [4]
  162.     int dos            ; [4]
  163. readnb:    call clrmod        ; clear 25th line
  164.     call rprpos        ; Put prompt here.
  165. read51a:jmp rskp
  166. read6:     call serrst        ; Reset serial port. [14]
  167.     cmp flags.xflg,0    ; Did we write out to screen? [21c]
  168.     je read61        ; No so print status. [21c]
  169.     cmp flags.destflg,2    ; Receiving to screen? [27c]
  170.     je read7a        ; Yes don't reset. [27c]
  171.     mov flags.xflg,0    ; Reset it. [21c]
  172.     jmp rskp        ; Print onto screen. [21c]
  173. read61:    cmp flags.remflg,0    ; remote mode?
  174.     jne read7a        ; yes, no printing.
  175.     call stpos        ; Position cursor.  [21c]
  176.     mov ah,prstr
  177.     mov dx,offset infms4    ; Plus a little cuteness.
  178.     int dos
  179.     cmp flags.belflg,0    ; Bell desired?  [17a]
  180.     je read7        ; No.  [17a]
  181.     mov dx,offset ender    ; Ring them bells.   [4]
  182.     int dos            ;  [4]
  183. read7:    call clrmod        ; clear mode line
  184.     call rprpos        ; Put prompt here.
  185. read7a:    jmp rskp
  186. READ    ENDP
  187.  
  188.  
  189. ;    Receive routines
  190.  
  191. ;    Receive init
  192.  
  193. RINIT    PROC    NEAR
  194.     mov ah,pack.numtry    ; Get the number of tries.
  195.     cmp ah,imxtry        ; Have we reached the maximum number of tries?
  196.     jl rinit2
  197.     call erpos        ; Position cursor.
  198.     mov dx,offset ermes7
  199.     mov ah,prstr
  200.     int dos            ; Print an error message.
  201.     mov bx,dx
  202.     call errpack        ; Send error packet just in case.
  203.     jmp abort        ; Change the state to abort.
  204. rinit2: inc ah            ; Increment it.
  205.     mov pack.numtry,ah    ; Save the updated number of tries.
  206.     mov ax,pack.argbk2    ; get packet type if here from get
  207.     cmp flags.getflg,1    ; Have we already read in the packet? [21a] 
  208.     je rin21a        ; Yes, so don't call RPACK. [21a]
  209.     mov ah,trans.chklen
  210.     mov curchk,ah        ; Save checksum length we want to use.
  211.     mov trans.chklen,1    ; Use 1 char for init packet.
  212.     call rpack        ; Get a packet.
  213.      jmp rin22        ; Trashed packet: nak, retry.
  214.     push ax
  215.     mov ah,curchk
  216.     mov trans.chklen,ah    ; Reset to desired value.
  217.     pop ax
  218. rin21a:    cmp ah,'S'        ; Is it a send initiate packet?
  219.     jne rinit3        ; If not see if its an error.
  220. rin21:    mov flags.getflg,0    ; Reset flag. [21a]
  221.     mov ah,pack.numtry    ; Get the number of tries.
  222.     mov pack.oldtry,ah    ; Save it.
  223.     mov pack.numtry,0    ; Reset the number of tries.
  224.     mov ax,pack.argblk    ; Returned packet number.  (Synchronize them.)
  225.     inc ax            ; Increment it.
  226.     and ax,3FH        ; Turn off the two high order bits.
  227.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  228.     mov bx,pack.numpkt
  229.     inc bx            ; Increment the number of packets.
  230.     mov pack.numpkt,bx
  231.     mov ax,pack.argbk1    ; Get the number of arguments received.
  232.     mov bx,offset data    ; Get a pointer to the data.
  233.     call spar        ; Get the data into the proper variables.
  234.     mov bx,offset data    ; Get a pointer to our data block.
  235.     call rpar        ; Set up the receive parameters.
  236.     xchg ah,al
  237.     mov ah,0
  238.     mov pack.argbk1,ax    ; Store the returned number of arguments.
  239.     mov ah,trans.chklen    ; Checksum length we'll use.
  240.     mov curchk,ah        ; Save it.
  241.     mov trans.chklen,1    ; Use 1 char for init packet.
  242.     mov ah,'Y'        ; Acknowledge packet.
  243.     call spack        ; Send the packet.
  244.      jmp abort
  245.     mov ah,curchk        ; Checksum length we'll use.
  246.     mov trans.chklen,ah    ; Reset to desired value.
  247.     mov ah,'F'        ; Set the state to file send.
  248.     mov pack.state,ah
  249.     ret
  250. rin22:    mov ah,curchk
  251.     mov trans.chklen,ah    ; Reset to desired value.
  252.     jmp nak0        ; Try again.
  253. rinit3: cmp ah,'E'        ; Is it an error packet?
  254.     jne rinit4
  255.     call error
  256. rinit4:    jmp abort
  257. RINIT    ENDP
  258.  
  259.  
  260. ;    Receive file
  261.  
  262. RFILE    PROC    NEAR
  263.     cmp pack.numtry,maxtry    ; Have we reached the maximum number of tries?
  264.     jl rfile1
  265.     call erpos        ; Position cursor.
  266.     mov dx,offset ermes8
  267.     mov ah,prstr
  268.     int dos            ; Print an error message.
  269.     mov bx,dx
  270.     call errpack        ; Send error packet just in case.
  271.     jmp abort        ; Change the state to abort.
  272. rfile1: inc pack.numtry        ; Save the updated number of tries.
  273.     call rpack        ; Get a packet.
  274.      jmp nak0        ;  Trashed packet: nak, retry.
  275.     cmp ah,'S'        ; Is it a send initiate packet?
  276.     je rfil10
  277.     call dodec        ; Decode all incoming packets.
  278.     jmp rfile2        ;  No, try next type.
  279. rfil10:    cmp pack.oldtry,imxtry    ; Have we reached the maximum number of tries?
  280.     jl rfil12        ; If not proceed.
  281.     call erpos        ; Position cursor.
  282.     mov dx,offset ermes7
  283.     mov ah,prstr
  284.     int dos            ; Print an error message.
  285.     mov bx,dx
  286.     call errpack        ; Send error packet just in case.
  287.     jmp abort        ; Change the state to abort.
  288. rfil12: inc pack.oldtry        ; Save the updated number of tries.
  289.     mov ax,pack.pktnum    ; Get the present packet number.
  290.     cmp ax,0        ; Had we wrapped around? [18 start]
  291.     jne rfilx 
  292.     mov ax,64
  293. rfilx:  dec ax            ; Decrement.  [18 end -- new label]
  294.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  295.     je rfil13
  296.     jmp nak0        ; No, NAK and try again.
  297. rfil13: call updrtr        ; Update retry count.
  298.     mov pack.numtry,0    ; Reset the number of tries.
  299.     mov bx,offset data    ; Get a pointer to our data block.
  300.     call rpar        ; Set up the parameter information.
  301.     xchg ah,al
  302.     mov ah,0
  303.     mov pack.argbk1,ax    ; Save the number of arguments.
  304.     mov ah,'Y'        ; Acknowledge packet.
  305.     call spack        ; Send the packet.
  306.      jmp abort
  307.     ret
  308. rfile2: cmp ah,'Z'        ; Is it an EOF packet?
  309.     jne rfile3        ;  No, try next type.
  310.     cmp pack.oldtry,maxtry    ; Have we reached the maximum number of tries?
  311.     jl rfil21        ; If not proceed.
  312.     call erpos        ; Position cursor.
  313.     mov dx,offset ermes9
  314.     mov ah,prstr
  315.     int dos            ; Print an error message.
  316.     mov bx,dx
  317.     call errpack        ; Send error packet just in case.
  318.     jmp abort        ; Change the state to abort.
  319. rfil21: inc pack.oldtry        ; Increment it.
  320.     mov ax,pack.pktnum    ; Get the present packet number.
  321.     cmp ax,0        ; Had we wrapped around? [18 start]
  322.     jne rfily
  323.     mov ax,64
  324. rfily:  dec ax            ; Decrement.  [18 end -- new label]
  325.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  326.     je rfil24
  327.     jmp nak0        ; No, NAK and try again.
  328. rfil24: call updrtr        ; Update retry count.
  329.     mov pack.numtry,0
  330.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  331.     mov cx,0
  332.     call doenc
  333.     mov ah,'Y'        ; Acknowledge packet.
  334.     call spack        ; Send the packet.
  335.      jmp abort
  336.     ret
  337. rfile3: cmp ah,'F'        ; Start of file?
  338.     je rfil31        ; Yes. [21c]
  339.     cmp ah,'X'        ; Text header packet? [21c]
  340.     jne rfile4        ; Neither one. 
  341. rfil31: mov ax,pack.argblk    ; Get the packet number. [21c]
  342.     cmp ax,pack.pktnum    ; Is it the right packet number?
  343.     je rfil32
  344.     jmp nak            ; No, NAK it and try again.
  345. rfil32: inc ax            ; Increment the packet number.
  346.     and ax,3FH        ; Turn off the two high order bits.
  347.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  348.     inc pack.numpkt        ; Increment the number of packets.
  349.     call gofil        ; Get a file to write to.
  350.      jmp abort
  351.     mov filopn,1        ; Disk file open.
  352.     call init1        ; Initialize all the buffers.
  353.     mov ah,pack.numtry    ; Get the number of tries.
  354.     mov pack.oldtry,ah    ; Save it.
  355.     mov pack.numtry,0    ; Reset the number of tries.
  356.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  357.     mov cx,0
  358.     call doenc
  359.     mov ah,'Y'        ; Acknowledge packet.
  360.     call spack        ; Send the packet.
  361.      jmp abort
  362.     mov pack.state,'D'    ; Set the state to data receive.
  363.     ret
  364. rfile4: cmp ah,'B'        ; End of transmission.
  365.     jne rfile5
  366.     mov ax,pack.pktnum
  367.     cmp ax,pack.argblk    ; Do we match?
  368.     je rfil41
  369.     jmp nak            ; No, NAK it and try again.
  370. rfil41: mov pack.argbk1,0    ; No data.  (Packet number already in argblk).
  371.     mov cx,0
  372.     call doenc
  373.     mov ah,'Y'        ; Acknowledge packet.
  374.     call spack        ; Send the packet.
  375.      jmp abort
  376.     mov pack.state,'C'    ; Set the state to complete.
  377.     ret
  378. rfile5: cmp ah,'E'        ; Is it an error packet.
  379.     jne rfile6
  380.     call error
  381. rfile6: jmp abort
  382. RFILE    ENDP
  383.  
  384.  
  385. ;    Receive data
  386.  
  387. RDATA    PROC    NEAR
  388.     cmp pack.numtry,maxtry    ; Get the number of tries.
  389.     jl rdata1
  390.     call erpos        ; Position cursor.
  391.     mov dx,offset erms10
  392.     mov ah,prstr
  393.     int dos            ; Print an error message.
  394.     mov bx,dx
  395.     call errpack        ; Send error packet just in case.
  396.     jmp abort        ; Change the state to abort.
  397. rdata1: inc pack.numtry        ; Save the updated number of tries.
  398.     call rpack        ; Get a packet.
  399.      jmp nak0        ;  Trashed packet: nak, retry.
  400.     cmp ah,'D'        ; Is it a data packet?
  401.     je rdat11
  402.     call dodec        ; Decode data.
  403.     jmp rdata2        ;  No, try next type.
  404. rdat11: mov ax,pack.pktnum    ; Get the present packet number.
  405.     cmp ax,pack.argblk    ; Is the packet's number correct?
  406.     jz rdat14
  407.     cmp pack.oldtry,maxtry    ; Have we reached the maximum number of tries?
  408.     jl rdat12        ; If not proceed.
  409.     call erpos        ; Position cursor.
  410.     mov dx,offset erms10
  411.     mov ah,prstr
  412.     int dos            ; Print an error message.
  413.     mov bx,dx
  414.     call errpack        ; Send error packet just in case.
  415.     jmp abort        ; Change the state to abort.
  416. rdat12: inc pack.oldtry        ; Save the updated number of tries.
  417.     mov ax,pack.pktnum
  418.     cmp ax,0        ; Had we wrapped around? [18 start]
  419.     jne rdatx
  420.     mov ax,64
  421. rdatx:    dec ax            ; [14] [18 end -- new label]
  422.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  423.     je rdat13
  424.     jmp nak0        ; No, NAK it and try again.
  425. rdat13: call updrtr        ; Update retry count.
  426.     mov pack.numtry,0    ; Reset number of tries.
  427.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  428.     mov cx,0
  429.     call doenc
  430.     mov ah,'Y'        ; Acknowledge packet.
  431.     call spack        ; Send the packet.
  432.      jmp abort
  433.     ret
  434. rdat14: inc ax            ; Increment the packet number.
  435.     and ax,3FH        ; Turn off the two high order bits.
  436.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  437.     inc pack.numpkt        ; Increment the number of packets.
  438.     mov ah,pack.numtry    ; Get the number of tries.
  439.     mov pack.oldtry,ah    ; Save it.
  440.     mov ax,pack.argbk1    ; Get the length of the data.
  441.     cmp flags.cxzflg,0    ; Has the user typed a ¬X or ¬Z? [20c]
  442.     je rdt14x        ; No, write out the data.
  443.     cmp flags.abfflg,1    ; Discard incomplete files?
  444.     je rdat15        ; If yes don't write data out to file. [20c]
  445. rdt14x:    mov bx,offset data    ; Where the data is. [25]
  446.     call ptchr
  447.      jmp abort        ;  Unable to write out chars; abort.
  448. rdat15: mov pack.numtry,0    ; Reset the number of tries.
  449.     mov pack.argbk1,0    ; No data.  (Packet number still in argblk.)
  450.     mov cx,0
  451.     cmp flags.cxzflg,0    ; Interrupt file transfer? [20c]
  452.     je rdat16        ; Nope. [20c] 
  453.     mov bx,offset data    ; Send data in ACK in case remote... [20c] 
  454.     mov ah,flags.cxzflg    ; ... knows about ¬X/¬Z. [20c]
  455.     mov [bx],ah        ; Put data into the packet. [20c]
  456.     mov pack.argbk1,1    ; Set data size to 1. [20c]
  457.     mov cx,1
  458. rdat16: call doenc
  459.     mov ah,'Y'        ; Acknowledge packet.
  460.     call spack        ; Send the packet.
  461.      jmp abort
  462.     ret
  463. rdata2: cmp ah,'F'        ; Start of file?
  464.     je rdat20        ; Yup. [21c]
  465.     cmp ah,'X'        ; Text header packet? [21c]
  466.     jne rdata3        ;  No, try next type.
  467. rdat20: cmp pack.oldtry,maxtry    ; Reached the max number of tries? [21c]
  468.     jl rdat21        ; If not proceed.
  469.     call erpos        ; Position cursor.
  470.     mov dx,offset ermes8
  471.     mov ah,prstr
  472.     int dos            ; Print an error message.
  473.     mov bx,dx
  474.     call errpack        ; Send error packet just in case.
  475.     jmp abort        ; Change the state to abort.
  476. rdat21: inc pack.oldtry        ; Save the updated number of tries.
  477.     mov ax,pack.pktnum
  478.     cmp ax,0        ; Had we wrapped around? [18 start]
  479.     jne rdaty
  480.     mov ax,64
  481. rdaty:    dec ax            ; [14 Omitted accidentally - D.T.] [18 end]
  482.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  483.     je rdat22
  484.     jmp nak0        ; No, NAK it and try again.
  485. rdat22: call updrtr        ; Update retry count.
  486.     mov pack.numtry,0    ; Reset number of tries.
  487.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  488.     mov cx,0
  489.     call doenc
  490.     mov ah,'Y'        ; Acknowledge packet.
  491.     call spack        ; Send the packet.
  492.      jmp abort
  493.     ret
  494. rdata3: cmp ah,'Z'        ; Is it a EOF packet?
  495.     je rdat3x        ; [13]
  496.     jmp rdata4        ; Try and see if its an error. [13]
  497. rdat3x: mov ax,pack.pktnum    ; Get the present packet number. [13]
  498.     cmp ax,pack.argblk    ; Is the packet's number correct?
  499.     je rdat32
  500.     jmp nak0        ; No, NAK it and try again.
  501. rdat32: inc ax            ; Increment the packet number.
  502.     and ax,3FH        ; Turn off the two high order bits.
  503.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  504.     inc pack.numpkt
  505.     cmp flags.cxzflg,0    ; Do we want to discard the file? [20c]
  506.     jne rdt32x        ; Yes. [20c]
  507.     cmp pack.argbk1,1    ; One piece of data? [20c]
  508.     jne rdat33        ; Nope - finish writing out file? [20c]
  509.     mov bx,offset data    ; Get data area. [20c]
  510.     mov ah,[bx]        ; Get the data. [20c]
  511.     cmp ah,'D'        ; "D" for discard? [20c]
  512.     jne rdat33        ; Nope - write out file. [20c]
  513. rdt32x:    cmp flags.abfflg,0    ; Keep incomplete files?
  514.     je rdat33        ; Yes, go write it out.
  515.     cmp flags.xflg,1    ; Writing to the screen?
  516.     je rdt32y        ; Don't close "file".
  517.     mov ah,closf        ; First, close the file.
  518.     mov dx,offset fcb    ; Give the file parameters. [20c]
  519.     int dos            ; Kill it, ignore errors. [20c]
  520.     mov ah,delf        ; Delete the file if opened. [20c]
  521.     int dos
  522. rdt32y:    cmp flags.cxzflg,'X'    ; Kill one file or all? [20c]
  523.     jne rdat36        ; No so leave flag alone. [20c]
  524.     call cxmsg        ; Clear msg about interrupt. [20c]
  525.     mov flags.cxzflg,0    ; Reset - ¬X only kills one file. [20c]
  526.     jmp rdat36
  527. rdat33: mov bx,bufpnt        ; Get the dma pointer.
  528.     mov ax,80H
  529.     sub ax,chrcnt        ; Get the number of chars left in the DMA.
  530.     cmp flags.destflg,0    ; Add ¬Z if writing to printer.
  531.     je rdt33x
  532.     cmp flags.eofcz,0    ; should we write a ¬Z?
  533.     jz rdat35        ; no, keep going
  534.     cmp flags.xflg,0    ; writing to a file?
  535.     jne rdat35        ; no, skip ¬Z
  536. rdt33x:    cmp ax,80H        ;   [13 start]
  537.     jne rdat34
  538.     call outbuf        ; Write out buffer if no room for ¬Z.
  539.      jmp abort
  540.     mov ax,0        ;   [13 end]
  541.     inc chrcnt        ; Increment size by one (not two). [21b]
  542. rdat34: mov cl,'Z'-100O        ; Put in a ¬Z for EOF.
  543.     mov [bx],cl        ; Add it. [21c]
  544.     inc ax
  545.     dec chrcnt
  546. rdat35:    mov cx,chrcnt
  547.     mov temp,cx
  548.     call outbuf        ; Output the last buffer.
  549.      jmp abort        ; Give up if the disk is full.
  550.     mov ax,temp        ; Prepare for the function call.
  551.     call fixfcb
  552.     cmp flags.xflg,1    ; Writing to the screen?
  553.     je rdat37        ; Yes, don't close "file".
  554.     mov ah,closf        ; Close up the file.
  555.     mov dx,offset fcb
  556.     int dos
  557. rdat36:    cmp flags.destflg,1    ; Writing to disk?
  558.     je rdat37        ; Yes, skip next part.
  559.     cmp flags.xflg,1    ; Writing to screen?
  560.     je rdat37        ; Yes, skip this part.
  561.     mov dl,ff        ; Send a form feed.
  562.     mov ah,lstout        ; Write out to first printer.
  563.     int dos
  564. rdat37:    mov ah,pack.numtry    ; Get the number of tries.
  565.     mov pack.oldtry,ah    ; Save it.
  566.     mov pack.numtry,0    ; Reset the number of tries.
  567.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  568.     mov cx,0
  569.     call doenc
  570.     mov ah,'Y'        ; Acknowledge packet.
  571.     call spack        ; Send the packet.
  572.      jmp abort
  573.     mov pack.state,'F'
  574.     mov filopn,0        ; File closed now.
  575.     ret
  576. rdata4: cmp ah,'E'            ; Is it an error packet.
  577.     jne rdata5
  578.     call error
  579. rdata5: jmp abort
  580. RDATA    ENDP
  581.  
  582.  
  583. ; Jumping to this location is like retskp.  It assumes the instruction
  584. ;   after the call is a jmp addr.
  585.  
  586. RSKP    PROC    NEAR
  587.     pop bp
  588.     add bp,3
  589.     push bp
  590.         ret
  591. RSKP    ENDP
  592.  
  593. R    PROC    NEAR
  594.     ret
  595. R    ENDP
  596.  
  597. code    ends 
  598.     end
  599.  
  600.